package cn.tpshion.task.data;

import cn.tpshion.task.common.MsgAction;
import com.alibaba.fastjson.JSON;
import lombok.Data;

@Data
public class MsgData {

    private Integer action;

    private String data;

    public static MsgData of(MsgAction action, String data) {
        MsgData msgData = new MsgData();
        msgData.setAction(action.getAction());
        msgData.setData(data);
        return msgData;
    }

    public static String ofJson(MsgAction action, String data) {
        return JSON.toJSONString(of(action, data));
    }
}
